<template>
  <a-modal
    :open="open"
    width="680px"
    title="查看追溯码"
    centered
    :ok-button-props="{ disabled: !isCompleted }"
    ok-text="确定"
    :footer="null"
    @cancel="onCancel"
  >
    <div>
      <div class="border mb-2 px-2 py-1 rounded">
        <DrugInfo :value="{ ...rowData }" class-name="flex items-center truncate justify-between" />
      </div>
      <div class="max-h-[560px] overflow-y-scroll">
        <BaseTable :data-source="tableData" column-code="000757" max-fill :loading="loading" :pagination="pagination" row-key="lsh">
          <template #bodyCell="{ column }">
            <template v-if="column.dataIndex === 'action'">
              <a-button>删除</a-button>
            </template>
          </template>
        </BaseTable>
      </div>
    </div>
  </a-modal>
</template>
<script setup>
import DrugInfo from '../components/DrugInfo.vue'

const emit = defineEmits(['update:open', 'ok'])
const props = defineProps({
  open: {
    type: Boolean,
    default: false
  },
  rowData: {
    type: Object,
    default: () => ({})
  },
  tcCode: {
    type: String,
    default: ''
  }
})

const { loading, tableData, getData, pagination } = useTable({
  url: '/drugStorage/psiform/getTcCodeDrugList',
  immediate: false,
  formatParams: () => {
    return {
      cj: props.rowData.cj,
      formSn: props.rowData.formSn,
      gg: props.rowData.gg,
      mc: props.rowData.mc,
      ph: props.rowData.ph,
      tcCode: props.tcCode
    }
  }
})
const onCancel = () => {
  emit('update:open', false)
}
watch(
  () => props.open,
  (val) => {
    if (val) getData()
  }
)
</script>
<style lang="less" scoped></style>
